package com.fancy.learncenter.ui.view;

import android.app.Activity;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.fancy.learncenter.R;
import com.fancy.learncenter.common.MyApplication;

/**
 * Created by shiweiwei on 2018/1/4.
 */

public class CartoonAnalysisPopu extends BasePopupWindow {

    private String text;
    private TextView analysis_text;
    private ImageView close_image;
    private View layoutView;
    private View popopView;
    public CartoonAnalysisPopu(Activity mContext, String text, View layoutView) {
        super(mContext);
        this.text = text;
        this.layoutView = layoutView;
        initPopup();
    }




    private void initPopup() {
        popopView = LayoutInflater.from(MyApplication.context).inflate(R.layout.cartoon_analysis_layout, null);
        analysis_text = (TextView) popopView.findViewById(R.id.analysis_text);
        close_image = (ImageView) popopView.findViewById(R.id.close_image);
        if (!TextUtils.isEmpty(text)) {
            analysis_text.setText(text);
        }

        close_image.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                dismiss();
            }
        });


        setWidth(ViewGroup.LayoutParams.MATCH_PARENT);
        setHeight(ViewGroup.LayoutParams.MATCH_PARENT);

        setOutsideTouchable(false);

        setContentView(popopView);
    }

    @Override
    public void showPopupWindow() {
        super.showPopupWindow();

        showAtLocation(layoutView, Gravity.CENTER, 0, 0);
    }
}
